package com.bosssoft.service_order.service.impl;

import com.bosssoft.service_order.domain.dto.CartDTO;
import com.bosssoft.service_order.domain.po.Cart;
import com.bosssoft.service_order.mapper.CartMapper;
import com.bosssoft.service_order.service.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CartImpl implements CartService {

    @Autowired
    private CartMapper cartMapper;

    @Override
    public Boolean add(CartDTO cartDTO) {
        Cart cart = new Cart();
        cart.setGoodsId(cartDTO.getGoodsId());
        cart.setUserId(cartDTO.getUserId());
        return cartMapper.insert(cart) == 1;
    }

    @Override
    public Cart query(CartDTO cartDTO) {
        return cartMapper.selectById(cartDTO.getUserId());
    }

    @Override
    public Boolean delete(CartDTO cartDTO) {
        return cartMapper.deleteById(cartDTO.getUserId()) == 1;
    }
}
